/**
 * 
 */
package de.cbf.cam.dsa.model.entities.states;

import de.cbf.cam.dsa.model.entities.BattleChar;
import de.cbf.cam.dsa.model.entities.OneNPC;
import de.cbf.cam.dsa.model.entities.weapon.WeaponInUse;
import de.cbf.cam.dsa.model.entities.weapon.WeaponMeleeInUse;

/**
 * @author Nebelritter
 *
 */
public class StateOnGround extends OneState {

	/**
	 * 
	 */
	public StateOnGround() {
		description ="am Boden";
		stateType= POSITION;
	}

	@Override
	public void resolveOnCharacter(BattleChar character) {
		WeaponInUse weapon = character.getWeapon(OneNPC.Hand_Main);
		if (weapon instanceof WeaponMeleeInUse) {
			WeaponMeleeInUse weaponMelee = (WeaponMeleeInUse) weapon;
			weaponMelee.setATtack(weaponMelee.getATtack()-1);
			weaponMelee.setPArade(weaponMelee.getPArade()-3);			
		}
		WeaponInUse secondWeapon = character.getWeapon(OneNPC.Hand_Second);
		if (secondWeapon instanceof WeaponMeleeInUse&&!secondWeapon.equals(weapon)) {
			WeaponMeleeInUse weaponMelee = (WeaponMeleeInUse) weapon;
			weaponMelee.setATtack(weaponMelee.getATtack()-1);
			weaponMelee.setPArade(weaponMelee.getPArade()-3);			
		}
	}

	@Override
	public void restoreOnCharacter(BattleChar character) {
		WeaponInUse weapon = character.getWeapon(OneNPC.Hand_Main);
		if (weapon instanceof WeaponMeleeInUse) {
			WeaponMeleeInUse weaponMelee = (WeaponMeleeInUse) weapon;
			weaponMelee.setATtack(weaponMelee.getATtack()+1);
			weaponMelee.setPArade(weaponMelee.getPArade()+3);			
		}
		WeaponInUse secondWeapon = character.getWeapon(OneNPC.Hand_Second);
		if (secondWeapon instanceof WeaponMeleeInUse&&!secondWeapon.equals(weapon)) {
			WeaponMeleeInUse weaponMelee = (WeaponMeleeInUse) weapon;
			weaponMelee.setATtack(weaponMelee.getATtack()+1);
			weaponMelee.setPArade(weaponMelee.getPArade()+3);			
		}	
	}
}
